// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 获取当前的用户 GET /api/currentUser */
export async function currentUser(options?: { [key: string]: any }) {
  return request<{
    data: API.CurrentUser;
  }>('/api/currentUser', {
    method: 'GET',
    ...(options || {}),
  });
}



/** 此处后端没有提供注释 GET /api/notices */
export async function getNotices(options?: { [key: string]: any }) {
  return request<API.NoticeIconList>('/api/notices', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 获取规则列表 GET /api/rule */
export async function rule(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.RuleList>('/api/rule', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}


/** 更新规则 PUT /api/rule */
export async function updateRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'POST',
    data: {
      method: 'update',
      ...(options || {}),
    },
  });
}

/** 新建规则 POST /api/rule */
export async function addRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'POST',
    data: {
      method: 'post',
      ...(options || {}),
    },
  });
}


//Account
/** 登录接口 POST /api/login/account */
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {

  return request<API.LoginWebAPIResult>('/api/Account/login', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
/** 退出登录接口 POST /api/login/outLogin */
export async function outLogin(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/Account/Logout', {
    method: 'POST',
    ...(options || {}),
  });
}
export async function register(body: API.LoginParams, options?: { [key: string]: any }) {

  return request<API.LoginWebAPIResult>('/api/Account/register', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

export async function modifyBaseSetting(body: API.LoginWebAPIResult, options?: { [key: string]: any }) {
  return request('/api/Account/ModifyBaseSetting', {
    method: 'PUT',
    data: body,
    ...(options || {}),
  });
}

export async function avarterUpload(avatarFile: File, loginname: string, options?: { [key: string]: any }) {
  const formData = new FormData();  
  
  // 将文件和其他字段添加到 FormData 中  
  formData.append('avatar', avatarFile);  
  formData.append('loginname', loginname); 
  return request<number>('/api/Account/AvarterUpload', {
    method: 'POST',
     data: formData,
    ...(options || {}),
  });
}


/** Assets **/
export async function getAssets(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.AssetsList>('/api/Assets/GetAssets', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}
export async function getAssetsCategorySelect(
  params: {
    categoryclass: number;
  },
  // options?: { [key: string]: any },
) {
  return request<API.CategoryInfo[]>('/api/Assets/GetAssetsCategory', {
    method: 'GET',
    params: {
      ...params,
    },
    // ...(options || {}),
  });
}

export async function addAssets(body: API.AssetsListItem | undefined, options?: { [key: string]: any }) {
  return request('/api/Assets/AddAssets', {
    method: 'POST',
    data: body,
    ...(options || {}),
  });
}

//前端传body数组，后端[FromBody] List<int> key获取
export async function deleteAssets(body: (number | undefined)[], options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/Assets/DelAssets', {
    method: 'DELETE',
    // headers: {
    //   'Content-Type': 'application/json',
    // },
    data: body,
    ...(options || {}),
  });
}
export async function editAssets(body: API.AssetsListItem | undefined, options?: { [key: string]: any }) {
  return request('/api/Assets/EditAssets', {
    method: 'PUT',
    data: body,
    ...(options || {}),
  });
}

/** Category **/
export async function getCategory(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.CategoryList>('/api/Category/GetCategory', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

export async function getCategoryClassSelect() {
  return request<API.CategoryClassInfo[]>('/api/Category/GetCategoryClass', {
    method: 'GET',
  });
}

export async function addCategory(body: API.CategoryListItem | undefined, options?: { [key: string]: any }) {
  return request('/api/Category/AddCategory', {
    method: 'POST',
    data: body,
    ...(options || {}),
  });
}

//前端传body数组，后端[FromBody] List<int> key获取
export async function deleteCategory(body: (number | undefined)[], options?: { [key: string]: any }) {
  return request('/api/Category/DelCategory', {
    method: 'DELETE',
    data: body,
    ...(options || {}),
  });
}
export async function editCategory(body: API.CategoryListItem | undefined, options?: { [key: string]: any }) {
  return request('/api/Category/EditCategory', {
    method: 'PUT',
    data: body,
    ...(options || {}),
  });
}

/** CategoryClass **/
export async function getCategoryClass(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.CategoryClassList>('/api/CategoryClass/GetCategoryClass', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

export async function addCategoryClass(body: API.CategoryClassListItem | undefined, options?: { [key: string]: any }) {
  return request('/api/CategoryClass/AddCategoryClass', {
    method: 'POST',
    data: body,
    ...(options || {}),
  });
}

//前端传body数组，后端[FromBody] List<int> key获取
export async function deleteCategoryClass(body: (number | undefined)[], options?: { [key: string]: any }) {
  return request('/api/CategoryClass/DelCategoryClass', {
    method: 'DELETE',
    data: body,
    ...(options || {}),
  });
}
export async function editCategoryClass(body: API.CategoryClassListItem | undefined, options?: { [key: string]: any }) {
  return request('/api/CategoryClass/EditCategoryClass', {
    method: 'PUT',
    data: body,
    ...(options || {}),
  });
}

/** Organization **/
export async function getOrganization(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.OrganizationList>('/api/Organization/GetOrganization', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

//获取一个用户的组织机构，发给个人中心上显示
export async function getUserOrganization(
  params: {
    dept: number;
    section: number;
    group:number;
  },
  options?: { [key: string]: any },
) {
  return request<API.OrganizationListItem>('/api/Organization/GetUserOrganization', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}


export async function getOrganizationDeptSelect() {
  return request<API.OrganizationDeptSelect[]>('/api/Organization/GetOrganizationDept', {
    method: 'GET',
  });
}

export async function getOrganizationSectionSelect(
  params: {
    dept: number;
  },
) {
  return request<API.OrganizationSectionSelect[]>('/api/Organization/GetOrganizationSection', {
    method: 'GET',
    params: {
      ...params,
    },
  });
}

export async function getOrganizationGroupSelect(
  params: {
    dept: number;
    section: number;
  },
) {
  return request<API.OrganizationGroupSelect[]>('/api/Organization/GetOrganizationGroup', {
    method: 'GET',
    params: {
      ...params,
    },
  });
}

export async function addOrganization(body: API.OrganizationListItem | undefined, options?: { [key: string]: any }) {
  return request('/api/Organization/AddOrganization', {
    method: 'POST',
    data: body,
    ...(options || {}),
  });
}

//前端传body数组，后端[FromBody] List<int> key获取
export async function deleteOrganization(body: (number | undefined)[], options?: { [key: string]: any }) {
  return request('/api/Organization/DelOrganization', {
    method: 'DELETE',
    data: body,
    ...(options || {}),
  });
}
export async function editOrganization(body: API.OrganizationListItem | undefined, options?: { [key: string]: any }) {
  return request('/api/Organization/EditOrganization', {
    method: 'PUT',
    data: body,
    ...(options || {}),
  });
}


export async function editPwd(body: API.PwdEditBody | undefined, options?: { [key: string]: any }) {
  return request('/api/Account/ModifyPwd', {
    method: 'PUT',
    data: body,
    ...(options || {}),
  });
}